package com.trp.model.psr;

import com.trp.model.CIMModel;

import java.util.HashMap;


public class CircuitSection extends PSR {

	private Circuit mParent;

	private HashMap<String, PSR> mPSRs;

	public CircuitSection(Circuit parent, String id, String name) {
		super(id, name);
		this.mParent = parent;
		mPSRs = new HashMap<String, PSR>();
	}

	@Override
	protected void init() {
	    this.mType = CIMModel.Type.CIRCUIT_SECTION;
	}


	public void addPsr(PSR psr) {
		if (psr == null || psr.getID() == null || psr.getID().isEmpty()) {
			throw new NullPointerException(" can not add null psr to circuit section!");
		}
		mPSRs.put(psr.getID(), psr);
	}

	public void removePsr(PSR psr) {
		mPSRs.remove(psr);
	}

	public PSR getPsr(String id) {
		return mPSRs.get(id);
	}

	public boolean exists(PSR psr) {
		return mPSRs.containsValue(psr);
	}

	public Circuit getParent() {
		return mParent;
	}
}
